<template>
  <div class="public-activities">
    <h1>校园活动列表</h1>
    <ul>
      <li v-for="activity in activities" :key="activity.id">
        <router-link :to="'/public-activities/' + activity.id">
          {{ activity.title }} - {{ activity.date }}
        </router-link>
      </li>
    </ul>
  </div>
</template>

<script>
import activities from '../assets/hw10_activities.json'; // 假设活动数据存储在assets/hw10_activities.json中

export default {
  name: 'PublicActivities',
  data() {
    return {
      activities: activities
    }
  },
  created() {
    console.log('Loaded activities:', this.activities);
  }
}
</script>

<style scoped>
.public-activities {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
}
ul {
  list-style: none;
  padding: 0;
}
li {
  margin: 10px 0;
  padding: 10px;
  border: 1px solid #eee;
}
a {
  color: #42b983;
  text-decoration: none;
}
</style>